import paddle
from paddle import nn
from paddle.nn.functional import binary_cross_entropy_with_logits
class BCEWithLogitsLoss2d(nn.Layer):
    def __init__(self,ignore_label=255):
        super(BCEWithLogitsLoss2d,self).__init__()
    def forward(self,inputs,labels):
        #inputs:[batch,1,h,w]
        #labels:[batch,h,w]
        inputs = inputs.reshape([-1]).astype('float32')
        labels = labels.reshape([-1]).astype('float32')
        return binary_cross_entropy_with_logits(inputs,labels)